package Poker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class Poker {
    public static void main(String[] args) {
        /**
         * 集合复习
         * 构建一副扑克，斗地主
         * 内容构建扑克，发牌，洗牌，看牌
         */
        String[] num={"A","2","3","4","5","6","7","8","9","10","J","Q","K"};
        /*黑桃 红桃 梅花 方片*/
        String[] picture={"♠","♥","♣","♦"};

        //key取值 value存值
        HashMap<Integer,String> value=new HashMap<>();
        ArrayList<Integer> key=new ArrayList<>();
        //计数 key键
        int tem = 0;
        //扑克
        for (int i = 0; i < picture.length; i++) {
            for (int j = 0; j < num.length; j++) {
                value.put(tem,picture[i]+num[j]);
                key.add(tem);
                tem++;
            }
        }
        value.put(tem,"大王");
        key.add(tem++);
        value.put(tem,"小王");
        key.add(tem);

        //洗牌(工具)
        Collections.shuffle(key);

        //发牌（斗地主）tree有序
        TreeSet<Integer> Li=new TreeSet<>();
        TreeSet<Integer> Wei=new TreeSet<>();
        TreeSet<Integer> Hua=new TreeSet<>();
        TreeSet<Integer> Boss=new TreeSet<>();

        for (int i = 0; i < key.size(); i++) {

            if(i >= key.size()-3){
                Boss.add(key.get(i));
            }else if(i % 3 == 0 ){
                Li.add(key.get(i));
            }else if(i % 3 == 1){
                Wei.add(key.get(i));
            }else {
                Hua.add(key.get(i));
            }
        }
        /**
         * 看牌 较麻烦
         */
        /*for (Integer l: li){
            System.out.print(value.get(l));
        }
        System.out.println();
        for (Integer w: Wei){
            System.out.print(value.get(w));
        }
        System.out.println();
        for (Integer h: Hua){
            System.out.print(value.get(h));
        }
        System.out.println();
        for (Integer b: Boss){
            System.out.print(value.get(b));
        }*/
        kanPoker(value,Li,"Li");
        kanPoker(value,Wei,"Wei");
        kanPoker(value,Hua,"Hua");
        kanPoker(value,Boss,"Boss");
    }

    private static void kanPoker(HashMap<Integer, String> value, TreeSet<Integer> li ,String name) {
        System.out.print(name+":");
        for (Integer l: li){
            System.out.print(value.get(l));
        }
        System.out.println();
    }

}
